<foreach name="members" item="mem">
    <tr>
        <td><input type="checkbox" class="check_list" name="member_id[]" value="{$mem['member_id']}"/></td>
        <td>{$mem.member_id}</td>
        <td>{$mem.member_name}</td>
        <td>{$mem.mobile}</td>
        <td>{$mem['wx']}</td>
        <td>{$mem['address']}</td>
        <td>{$mem['agent_name']}</td>
        <td>{$mem['send_time']}</td>
    </tr>
</foreach>
<tr><td colspan="8">{$page}</td></tr>
<script type="text/javascript">
    $(document).ready(function(){
        $("#assign").click(function(){
            $("#assign_form").submit();
        });

        $(".pagination a").click(function(){
            cur_page = $(this).data('p');
            ajax_get_table(cur_page);
        });

        $("#check_all").click(function(){
            $("input[class='check_list']").prop('checked', $(this).prop("checked"));
        });

        $("#search_to").keyup(function(){
            $aName = $(this).val();
            if($aName != ''){
                getAgentName();
            }else{
                return false;
            }
        });

//        $("#assign").click(function(){
//            $to = $("#to").val();
//            if($to == '' || !$to){
//                layer.alert("请选择代理");
//                return false;
//            }else{
//                $("#assign_form").submit();
//            }
//        });

        $("#search_to").change(function(){
            $aName = $(this).val();
            if($aName != ''){
                getAgentName();
            }else{
                return false;
            }
        });

        function getAgentName()
        {
            $.ajax({
                url: "{:U('Members/searchAgent')}",
                type: "post",
                data: {aName : $aName},
                success: function (data) {
                    if (data) {
                        options = "";
                        $.each(data, function(k, v){
                            options += '<option value="'+ v.agent_id +'">'+ v.agent_name +'  '+v.mobile+'</option>';
                        });
                        $("#to").html(options);
                    }
                }
            });
        }
    });
</script>